package com.example.houseman.controller;


import com.example.houseman.entity.TbRoomReservation;
import com.example.houseman.service.ITbRoomReservationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.org.dto.RoomReservationDto;
import com.org.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 预约房源表 前端控制器
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/hou/TbRoomReservationController")
public class TbRoomReservationController {

    @Autowired
    private ITbRoomReservationService roomReservationService;


    @RequestMapping("selects")
    public ResultEntity selects(RoomReservationDto roomReservationDto){
        PageHelper.startPage(roomReservationDto.getPageNum(),roomReservationDto.getPageSize());
        List<TbRoomReservation> list = roomReservationService.selects(roomReservationDto);

        PageInfo<TbRoomReservation> info = new PageInfo<>(list);
        return ResultEntity.ok("200","查询成功",info);
    }


    @RequestMapping("update")
    public boolean update(Integer status,String[] ids){
        try {
            roomReservationService.update(status,ids);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }


}
